<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>

</body>
<script>
	
	
	
	
	
	
	
	
	// 没有使用await的async函数
	async function fn5() {
		return 4
	}
	function fn1() {
		return Promise.resolve(1)
	}
	function fn2() {
		return 2
	}
	function fn3() {
		return Promise.reject(3)
		//  return fn3.test()
	}
	function fn4() {
		return fn3.test()
	}
	async function fn() {
		// await右侧是一个成功的promise
		// const result = await fn1();// fulfilled 1
		// await右侧是一个非promise的数据
		// const result = await fn2();// 2
		
		// await右侧是一个失败的promise
		// const result = await fn3();
		// await右侧抛出异常
		const result = await fn4()
		console.log('result: ', result);
		return result+10;// 12
	}
	async function test() {
		// try {
		// 	const result2 = await fn();
		// 	console.log('result2', result2);
		// } catch (error) {
		// 	console.log('error', error);
		// }
		
		try{
			const result3 = await fn4()
			console.log('result4', result3);
		}catch (err) {
			console.log(err);
		}
		
	}
	test()
</script>
</html>